﻿using System;
using System.Windows.Forms;
using HighDiveAdmin.Engine;
using HighDiveEngine.Aggregates;
using HighDiveEngine.Model;

namespace HighDiveAdmin.GUI
{
    public partial class StartContestList : Form
    {
        public int? Index { get; set; }
        public StartContestList(ContestList contestList)
        {
            InitializeComponent();
            listBoxContests.DataSource = contestList;
        }

        private void buttonOk_Click(object sender, EventArgs e)
        {
            Index = ((Contest) listBoxContests.Items[listBoxContests.SelectedIndex]).DbId;
            DialogResult = DialogResult.OK;
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
        }

        private void listBoxContests_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (e.Y > listBoxContests.SelectedIndex * 15 && e.Y < listBoxContests.SelectedIndex * 15 + 15)
            {
                Index = ((Contest)listBoxContests.Items[listBoxContests.SelectedIndex]).DbId;
                DialogResult = DialogResult.OK;
            }
        }
    }
}
